from django.db import models
from django.contrib.auth.models import User

LogChoise = ((0, 'Registrar Almacen'),
                (1, 'Dar de baja Almacen'),
                (2, 'Iniciar sesion'),
                (3, 'Finalizar sesion'),
                (4, 'Registrar tipo item'),
                (5, 'Eliminar tipo item'),
                (6, 'Registrar item'),
                (7, 'Eliminar item'),
                (8, 'Registrar Cliente'),
                (9, 'Registrar Vinyl'),
                (10, 'Registrar Rueda'),
                (11, 'Eliminar Vinyl'),
                (12, 'Eliminar Rueda'),
                (13, 'Agregar Vinyl'),
                (14, 'Agregar Rueda'),
                (15, 'Realizar Venta'),
                (16, 'Registrar Moneda'),
                (17, 'Modificar Moneda'),
                (18, 'Registrar Vendedor'),
                (19, 'Eliminar Vendedor'),
                (20, 'Registrar Proveedor'),
                (21, 'Registrar Adquisicion'),
                (22, 'Cerrar Adquisicion'),
                (23, 'Eliminar Adquisicion'),
                (24, 'Pagar'),
               )

class Person(models.Model):
    user = models.ForeignKey(User)
    def __unicode__(self):
        return u'%s' % (self.user.get_full_name())
    
class Phone(models.Model):
    number = models.CharField(max_length=30, null=False, blank=False)
    detail = models.CharField(max_length=50, null=False, blank=False)
    person = models.ForeignKey(Person)
    def __unicode__(self):
        return u'%s' % (self.number)
    
class Client(Person):
    nit = models.CharField(max_length=30, null=True, blank=True)
    comment = models.TextField(null=False, blank=False)
    def __unicode__(self):
        return u'%s' % (self.user.get_full_name())
    
class Vendor(Person):
    is_owner = models.BooleanField(null=False, blank=False, default=False)
    def __unicode__(self):
        return u'%s' % (self.user.get_full_name())

class Provider(Person):
    def __unicode__(self):
        return u'%s' % (self.user.get_full_name())

class Log(models.Model):
    id_user = models.ForeignKey(User)
    action = models.IntegerField(choices=LogChoise, null=False, blank=False)
    id_action = models.IntegerField(null=False, blank=False)
    datetime = models.DateTimeField(null=False, blank=False)
    def __unicode__(self):
        return u'log'
